﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BomberManServer.Gaming.Object.Mapping.Items;
using BomberManServer.Utils;


/// Description :
/// <   This object is the Avatar's bonus's modification controler. 
///     It allows to reset the avatar's attributes to their starting 
///     values at the end of a round >
namespace BomberManServer.Gaming.Object.Bonuses
{
    public class Modifier
    {
        private UInt32 speedBasic;
        private float delayBasic;
        private UInt32 nbBombBasic;
        private UInt32 deflagBasic;

        private Avatar avatar;

        public Modifier(Avatar avatar)
        {
            this.speedBasic = avatar.speed;
            this.deflagBasic = avatar.deflag_length;
            this.nbBombBasic = avatar.bomb_max;
            this.delayBasic = avatar.bomb_delay;
            this.avatar = avatar;
        }

        public void modify(Bonus.Type type)
        {
            switch (type)
            {
                case Bonus.Type.BOMB:
                    avatar.bomb_max += Constants.instance.permPower;
                    break;
                case Bonus.Type.DELAY:  
                    avatar.bomb_delay += (UInt32)(Constants.instance.permPower * Constants.instance.actions_per_second * Constants.instance.delayCoef);
                    break;
                case Bonus.Type.RANGE:
                    avatar.deflag_length += Constants.instance.permPower;
                    break;
                case Bonus.Type.SPEED:
                    avatar.speed += Constants.instance.permPower * Constants.instance.speedCoef;
                    break;
                default:
                    break;
            }
        }

        public void reset()
        {
            avatar.speed = speedBasic;
            avatar.deflag_length = deflagBasic;
            avatar.bomb_max = nbBombBasic;
            avatar.bomb_delay = delayBasic;
            avatar.hasKick = false;
        }
    }
}
